//
//  MainWindowController.m
//  test-ArrayControllerTableView
//
//  Created by 杨岑 on 10/9/15.
//  Copyright © 2015 杨岑. All rights reserved.
//

#import "MainWindowController.h"

@interface MainWindowController ()
@property (weak) IBOutlet NSTableView *tableView;
@property (weak) IBOutlet NSArrayController *objects;
@end

@implementation MainWindowController

- (IBAction)add_click:(id)sender {
    static int counter;
    
    NSMutableDictionary* object = [NSMutableDictionary dictionary];
    object[@"Key"] = [NSString stringWithFormat:@"Key#%d", counter];
    object[@"Value"] = [NSString stringWithFormat:@"Value#%d", counter];
    counter++;
    [self.objects addObject:object];
}

- (IBAction)remove_click:(id)sender {
    if (self.objects.selectionIndexes.count > 0) {
        [self.objects removeObjects:self.objects.selectedObjects];
    }
}

@end
